home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
spellr20.zip
/
SPELLR.M
< prev
Wrap
Text File
|
1988-09-11
|
16KB
|
546 lines
(extern add_to_path next_error _check_warnings)
;=======================================================================
; This routine spell checks the file in the current buffer using the
; current file in the buffer.
;=======================================================================
(macro spellr (
(string
file_name ;** The name of the file we're compiling.
extension ;** The file name extension
command_line ;** The compile command line.
path ;** The path of the file we're compiling.
old_path ;** The original path we were on.
error_file ;** The file to put error information in.
)
(int
loc ;** Generic index place holder.
ret_code ;** Return code from DOS.
buffer_id ;** Buffer ID of error buffer.
check_warnings ;** Examine resule of compile for errors?
tab_length ;** length of tab stops
)
;(pause_on_error 1)
(inq_names path extension file_name)
(= ret_code 1)
;===================================================================
; If the file has been modified, we want to make sure the current
; version gets spell checked, so we write it to disk.
;===================================================================
(if (inq_modified) (
(int old_msg_level)
(= old_msg_level (inq_msg_level))
(set_msg_level 0)
(= ret_code (write_buffer))
(set_msg_level old_msg_level)
))
(if (>= ret_code 0) (
;===============================================================
; Now we parse the filename off the path string making sure to
; handle the possible presence of forward and backward slash
; characters. We then replace the file_name's extension with
; ".err" for redirection purposes.
;===============================================================
(= path (substr path 1 (rindex path (substr path 3 1))))
(if (> (strlen path) 3)
(= path (substr path 1 (- (strlen path) 1)))
)
(= file_name (substr file_name 1 (- (index file_name ".") 1)))
(= error_file (+ file_name ".err"))
(= ret_code 0)
;===============================================================
; We want any file generated to end up in the file's directory,
; so we change to the directory where the file is, saving the
; current directory. We also make the file's drive the default
; drive.
;===============================================================
(getwd "" command_line)
(getwd path old_path)
(= old_path (+ (substr command_line 1 1) (substr old_path 2)))
(cd path)
(cd (substr path 1 2))
;===============================================================
; If there is already a buffer for the error file, we "create"
; it (create_buffer returns the ID of a buffer that already
; existed) and the delete it immediately. Note that under some
; very obscure circumstances, the create+buffer call could fail.
; If it does, it'll return 0, which is an invalid buffer id. We
; check for this case since delete_buffer does not.
;===============================================================
(if (= buffer_id (create_buffer "SpellR Err" error_file 1))
(delete_buffer buffer_id)
)
;===============================================================
; Get the current tab distance
;===============================================================
(move_abs 0 1)
(= tab_length (distance_to_tab))
;===============================================================
; Output the command line and then execute it.
;===============================================================
(sprintf command_line "spellr -t%d " tab_length)
(+= command_line file_name)
(if (strlen extension) (
(+= command_line ".")
(+= command_line extension)
))
(+= command_line " >& ")
(+= command_line error_file)
(message command_line)
(= ret_code (dos command_line 0))
(if (> ret_code 0) (
(next_error)
))
(del error_file)
(if (== ret_code 0)
(message "SpellR successful.")
)
(cd (substr old_path 3))
(cd (substr old_path 1 2))
))
(returns ret_code)
))
;**
;** BRIEF -- Basic Reconfigurable Interactive Editing Facility
;**
;** Written by Dave Nanian and Michael Strickman.
;**
;** errorfix.m
;**
;** This file contains the main driver and support macros for BRIEF's
;** error location facility.
;**
#define TRUE 1
#define FALSE 0
#define WARNING 1
#define ERROR 2
(extern add_to_path
center_line
_exit
)
;**
;** next_error:
;**
;** This routine is the engine for BRIEF's error location facility. It
;** reads in the error file and calls the appropriate routines to display
;** either an individual error message or a window full of error message
;** information.
;**
;** If no parameter (or zero) is passed to next_error, the error file is
;** read into a buffer and searched for error messages. If the buffer is
;** empty, the message "No errors." is displayed and the error buffer is
;** removed. If the buffer is not empty, and a message can be located, the
;** text of the message is displayed on the message line, the cursor is placed
;** on the first non-blank character of the line containing the error, and that
;** line is centered in the window. If no messages can be located, the error
;** file is presented in a pop-up window.
;**
;** If a "1" is passed to next_error, the error information is displayed in
;** a window, with the current message highlighted. If no messages could be
;** recognised, the highlight is not displayed, and the cursor can be moved
;** anywhere within the file.
;**
;** If a "2" is passed to next_error, the error file is tested to see if
;** any messages can be recognised. If so, the same action is taken as with
;** next_error 0. If not, no message is displayed and the error file buffer
;** is deleted.
;**
;** In all cases, next_error returns 0 if no error was found, and non-zero
;** if there was an error.
;**
(macro next_error
(
(int error_buf
curr_buf
line
col
error_type
more_errors
prev_errors
errors_exist
action
windowed
_cancel_errorfix
)
(string error_msg
error_file
buf_name
parms
error_extension
)
(global _cancel_errorfix)
(inq_names error_file error_extension buf_name)
(= curr_buf (inq_buffer))
(= _cancel_errorfix FALSE)
(if (strlen error_extension) (
(= error_file (substr error_file 1 (- (rindex error_file ".") 1)))
(= error_extension (+ "." error_extension))
)
;else
(
(= error_extension ".")
))
(+= error_file ".err")
(= parms (+ (+ error_extension " ") buf_name))
(if (! (= error_buf (create_buffer "Error File" error_file TRUE)))
(return FALSE)
)
(set_buffer error_buf)
(save_position)
(top_of_buffer)
(= errors_exist (end_of_buffer))
(restore_position)
(get_parm 0 action)
(if (! errors_exist)
(
(if (!= action 2)
(message "No errors.")
)
)
;else
(
(= windowed (== action 1))
(save_position)
(= more_errors (execute_macro (+ "_call_next " parms)))
(if (&& more_errors windowed)
(execute_macro (+ "_call_prev " parms))
;else
(
(down)
(save_position)
(= prev_errors (execute_macro (+ "_call_prev " parms)))
(restore_position)
(restore_position)
(save_position)
)
)
(= errors_exist (|| more_errors prev_errors))
(if (= windowed (&& (!= action 2) (|| windowed (! errors_exist))))
(
(int lines
cols
)
(keyboard_push)
(assign_to_key "<Enter>" "_exit")
(assign_to_key "<Esc>" "_error_cancel")
(assign_to_key "<Left>" "left")
(assign_to_key "<Right>" "right")
(assign_to_key "<Home>" "beginning_of_line")
(assign_to_key "<End>" "end_of_line")